function my_Proxy(proxy_array) {

    // 递归遍历对象属性，输出设置操作的日志
    function set_traverse_object(target, obj, recursion_layers) {
        recursion_layers -= 1; // 递归层数减少
        for (let prop in obj) { // 遍历对象的所有属性
            const value = obj[prop]; // 获取属性值
            const tg_name = `${target}.${prop.toString()}`; // 构造完整的属性名称
            const value_type = get_value_type(value); // 获取属性值的类型
            if (value && value_type === "object" && recursion_layers >= 1) { // 如果值是对象且递归层数大于1
                set_traverse_object(tg_name, value, recursion_layers); // 递归调用遍历函数
                continue;
            }
            if (value && value.toString() !== '[object Object]') { // 如果值不是普通对象
                console.log("方法:", "set设置  ", "对象:", tg_name,
                    "  属性:", value,
                    "  属性类型:", typeof value,
                    "  属性值类型:", value_type);
                continue;
            }
            console.log("方法:", "set设置  ", "对象:", tg_name,
                "  属性:", value,
                "  属性类型:", typeof value,
                "  属性值类型:", value_type);
        }
    }

    // 创建一个新的代理对象
    function new_handel(target_name, obj, number) {
        return new Proxy(obj, my_handler(target_name, number));
    }

    // 获取值的类型
    function get_value_type(value) {
        if (value && value.constructor && value.constructor === Array) {
            return 'Array';
        }

        return typeof value;
    }

    function Judge_window(target) {
        if (target + "" == '[object global]') {
            return true
        } else {
            return false
        }
    }

    // 处理器对象，定义了set、get和deleteProperty的捕捉器
    function my_handler(target_name, number) {
        return {
            // 设置属性值时的捕捉器
            set: function (obj, prop, value) {
                const value_type = get_value_type(value); // 获取值的类型
                const tg_name = `${target_name}.${prop.toString()}`; // 构造完整的属性名称

                if (value && value_type === "object") { // 如果值是对象

                    console.log("方法:", "set设置  ", "对象:", tg_name,
                        "  属性:", prop,
                        "  属性类型:", typeof prop,
                        "  结果:", value,
                        "  结果类型:", typeof value,);

                    set_traverse_object(tg_name, value, number); // 递归调用遍历函数
                } else {
                    console.log("方法:", "set设置  ", "对象:", tg_name,
                        "  属性:", value,
                        "  属性类型:", typeof value,
                        "  属性值类型:", value_type);
                }
                return Reflect.set(obj, prop, value); // 设置属性值
            },
            // 获取属性值时的捕捉器
            get: function (obj, prop) {

                const tg_name = `${target_name}.${prop.toString()}`; // 构造完整的属性名称
                const value = Reflect.get(obj, prop); // 获取属性值
                if (value && value.__proto__ == null) {
                    return value;
                }
                let value_type = get_value_type(value); // 获取值的类型
                if (value && value_type === 'object') { // 如果值是对象

                    console.log("方法:", "get获取  ", "对象:", tg_name,
                        "  属性:", prop,
                        "  属性类型:", typeof prop,
                        "  属性值类型:", typeof obj[prop]);

                    return new_handel(tg_name, value, number); // 返回新的代理对象
                } else if (value && value_type === "function") { // 如果值是对象
                    if (obj.name) {
                        console.log(obj.name + `调用了${String(prop)}方法`)
                    }
                    return new Proxy(value, {
                        set: (target, key, value) => {
                            console.log(tg_name, "：", target, `方法key：${key},"结果："${value}`);
                            return Reflect.set(target, key, value);
                        },
                        get: (target, key) => {
                            let value = Reflect.get(target, key);
                            console.log(tg_name, "：", target, `方法key：${String(key)}，结果：${value}`);
                            if (target !== globalThis && value instanceof Function) {
                                value = value.bind(target);
                            }
                            return value;
                        },
                        apply: (target, ctx, args) => {
                            let value = Reflect.apply(target, ctx, args)
                            console.log(tg_name, "：", '参数：', args, "结果：", value);
                            if (value && typeof value === 'object') { // 如果值是对象
                                console.log("方法2:", "set设置  ", "对象:", tg_name,
                                    "  属性:", prop,
                                    "  属性类型:", typeof prop,
                                    "  属性值类型:", typeof obj[prop]);
                                if (tg_name == 'window.RegExp') {
                                    return value
                                }
                                return new_handel(target.name, value, 30); // 返回新的代理对象
                            }
                            return value;
                        },
                    })
                }
                console.log("方法:", "get获取  ", "对象:", tg_name,
                    "  属性:", value,
                    "  属性类型:", typeof value,
                    "  属性值类型:", value_type);
                return value;
            },
            // 删除属性时的捕捉器
            deleteProperty(target, propKey) {
                let result = Reflect.deleteProperty(target, propKey); // 删除属性
                let value_type = get_value_type(result); // 获取删除结果的类型
                let targetname
                if (Judge_window(target)) {
                    targetname = 'window'
                } else {
                    targetname = target
                }
                console.log("方法:", "del删除  ", "对象:", targetname,
                    "  属性:", propKey,
                    "  属性类型:", typeof propKey,
                    "  属性值类型:", value_type);
                return result;
            }
        };
    }

    // 返回代理对象
    for (let i = 0; i < proxy_array.length; i++) {
        globalThis[proxy_array[i]] = new Proxy(globalThis[proxy_array[i]], my_handler(proxy_array[i], 30));
    }
    String.prototype.indexOf = new Proxy(String.prototype.indexOf, {
        apply: (target, ctx, args) => {

            let value = Reflect.apply(target, ctx, args);
            console.log('对象：', ctx, 'indexOf', '参数：', args, "结果：", value);
            return value;
        },
    })
    Array.prototype.indexOf = new Proxy(Array.prototype.indexOf, {
        apply: (target, ctx, args) => {
            debugger
            let value = Reflect.apply(target, ctx, args);
            console.log('对象：', ctx, 'indexOf', '参数：', args, "结果：", value);
            return value;
        },
    })
    Array.prototype.includes = new Proxy(Array.prototype.includes, {
        apply: (target, ctx, args) => {
            let value = Reflect.apply(target, ctx, args);
            // console.log("includes结果：", value);
            return value;
        },
    })

};


window = globalThis


aa = {
    'href': 'http://'
};
proxy_array = ['Object', 'aa',]
my_Proxy(proxy_array)

aa['b'] = '111';
g = aa['b']
g.indexOf("2222")
aa['c'] = {};
aa['c']['d'] = {};
Object.defineProperty(aa, 'ccc', {
    get: function () {
        return {
            d: function ccc(name) {
                return {}
            }
        }
    }
});
Object.hasOwn(aa, "dddddd")
sadsa = aa.ccc.d(2222)
sadsa['sadsad'] = '我是分割线'
aa.kk = function ddddd() {
    cc = {}
    return cc
}
m = aa.kk()
m['ddd'] = 11111
window.sd = m
m['ddd2'] = function ddddd2() {
    return {}
}
ll = m['ddd2']()
ll['ddd'] = function ddddd2() {
    return {}
}
llcc = ll['ddd']()
llcc['asdas'] = "窗帘拉上"
aa.kk.toString().indexOf("333333")
aa.kk.__proto__1 = "2222"
aa.kk.__proto__1.indexOf("sdsa")
aa.kk.__proto__2 = [222, 333]
aa.kk.__proto__2.indexOf("sdsa")
aa.kk.__proto__2.includes("sdsa")
km = {
    d: function () {
        return {"22": 222222}
    }
}
